package test;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpServer {
	
	public static void main(String[] args) throws Exception{
		byte[] buf=new byte[1024];
		DatagramSocket sk=new DatagramSocket(7777);
		DatagramPacket p=new DatagramPacket(buf, 1024);
		sk.receive(p);
		byte[] data=p.getData();
		String s=new String(data,0,p.getLength());
		System.out.println("rev:..."+s);
		
		InetAddress remoteAddr=p.getAddress();
		int remotePort=p.getPort();
		DatagramPacket sp=new DatagramPacket("guai...".getBytes(), 6, remoteAddr, remotePort);
		sk.send(sp);
		
		
		sk.close();
		
		
	}

}
